home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Visual Basic 5.0 (2nd Edition) / Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso / Code / TestEnum.frm < prev    next >
Text File  |  1997-06-14  |  6KB  |  220 lines

  1. VERSION 5.00
  2. Begin VB.Form FTestEnum 
  3.    Caption         =   "Test Enumerations"
  4.    ClientHeight    =   3480
  5.    ClientLeft      =   1995
  6.    ClientTop       =   1410
  7.    ClientWidth     =   5100
  8.    Icon            =   "TestEnum.frx":0000
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   3480
  11.    ScaleWidth      =   5100
  12.    Begin VB.CheckBox chkCase 
  13.       Caption         =   "Case Sensitive"
  14.       Height          =   312
  15.       Left            =   144
  16.       TabIndex        =   14
  17.       Top             =   1176
  18.       Value           =   1  'Checked
  19.       Width           =   1452
  20.    End
  21.    Begin VB.CommandButton cmdFind 
  22.       Caption         =   "Find"
  23.       Height          =   360
  24.       Left            =   156
  25.       TabIndex        =   12
  26.       Top             =   2940
  27.       Width           =   984
  28.    End
  29.    Begin VB.TextBox txtClass 
  30.       Height          =   348
  31.       Left            =   1200
  32.       TabIndex        =   9
  33.       Top             =   720
  34.       Width           =   948
  35.    End
  36.    Begin VB.TextBox txtTitle 
  37.       Height          =   348
  38.       Left            =   144
  39.       TabIndex        =   8
  40.       Top             =   720
  41.       Width           =   948
  42.    End
  43.    Begin VB.Frame fmEnum 
  44.       Caption         =   "Enumerations"
  45.       Height          =   1332
  46.       Left            =   2388
  47.       TabIndex        =   3
  48.       Top             =   96
  49.       Width           =   2388
  50.       Begin VB.OptionButton opt 
  51.          Caption         =   "Top Windows"
  52.          Height          =   250
  53.          Index           =   0
  54.          Left            =   84
  55.          TabIndex        =   7
  56.          Top             =   252
  57.          Width           =   1308
  58.       End
  59.       Begin VB.OptionButton opt 
  60.          Caption         =   "Child Windows "
  61.          Height          =   250
  62.          Index           =   1
  63.          Left            =   84
  64.          TabIndex        =   6
  65.          Top             =   492
  66.          Width           =   1428
  67.       End
  68.       Begin VB.OptionButton opt 
  69.          Caption         =   "Font Families"
  70.          Height          =   250
  71.          Index           =   2
  72.          Left            =   84
  73.          TabIndex        =   5
  74.          Top             =   732
  75.          Width           =   1356
  76.       End
  77.       Begin VB.OptionButton opt 
  78.          Caption         =   "Resources"
  79.          Height          =   250
  80.          Index           =   3
  81.          Left            =   84
  82.          TabIndex        =   4
  83.          Top             =   972
  84.          Width           =   1428
  85.       End
  86.    End
  87.    Begin VB.ListBox lstEnum 
  88.       Height          =   1035
  89.       Left            =   2388
  90.       TabIndex        =   1
  91.       Top             =   1584
  92.       Width           =   2436
  93.    End
  94.    Begin VB.CommandButton cmdExit 
  95.       Cancel          =   -1  'True
  96.       Caption         =   "Exit"
  97.       Height          =   372
  98.       Left            =   1260
  99.       MaskColor       =   &H00000000&
  100.       TabIndex        =   0
  101.       Top             =   2940
  102.       Width           =   972
  103.    End
  104.    Begin VB.Label lbl 
  105.       Caption         =   "Find Any Window"
  106.       Height          =   360
  107.       Index           =   0
  108.       Left            =   168
  109.       TabIndex        =   15
  110.       Top             =   120
  111.       Width           =   2088
  112.    End
  113.    Begin VB.Label lblFound 
  114.       Height          =   1176
  115.       Left            =   144
  116.       TabIndex        =   13
  117.       Top             =   1632
  118.       Width           =   2004
  119.    End
  120.    Begin VB.Label lbl 
  121.       Caption         =   "Class:"
  122.       Height          =   216
  123.       Index           =   2
  124.       Left            =   1188
  125.       TabIndex        =   11
  126.       Top             =   468
  127.       Width           =   972
  128.    End
  129.    Begin VB.Label lbl 
  130.       Caption         =   "Title:"
  131.       Height          =   216
  132.       Index           =   1
  133.       Left            =   144
  134.       TabIndex        =   10
  135.       Top             =   480
  136.       Width           =   972
  137.    End
  138.    Begin VB.Label lblResult 
  139.       Height          =   216
  140.       Left            =   2388
  141.       TabIndex        =   2
  142.       Top             =   3060
  143.       Width           =   2424
  144.    End
  145. End
  146. Attribute VB_Name = "FTestEnum"
  147. Attribute VB_GlobalNameSpace = False
  148. Attribute VB_Creatable = False
  149. Attribute VB_PredeclaredId = True
  150. Attribute VB_Exposed = False
  151. Option Explicit
  152.   
  153. Enum EEnumerations
  154.     eeTopWindows = 0
  155.     eeChildWindows
  156.     eeFontFamilies
  157.     eeResources
  158. End Enum
  159.  
  160. Private eeCur As EEnumerations
  161.  
  162. Private Sub cmdExit_Click()
  163.     Unload Me
  164. End Sub
  165.  
  166. Private Sub cmdFind_Click()
  167.     Dim hWnd As Long, sClass As String, sTitle As String
  168.     sTitle = txtTitle
  169.     sClass = txtClass
  170.     If sTitle = sEmpty And sClass = sEmpty Then Exit Sub
  171.     ' Hide text so we won't find entry textbox
  172.     txtTitle = sEmpty
  173.     txtClass = sEmpty
  174.     hWnd = FindAnyWindow(sTitle, sClass, chkCase)
  175.     txtTitle = sTitle
  176.     txtClass = sClass
  177.     If hWnd Then
  178.         lblFound = GetWndInfo(hWnd)
  179.     Else
  180.         lblFound = "No match"
  181.     End If
  182. End Sub
  183.  
  184. Private Sub Form_Load()
  185.     Dim ab() As Byte, s As String
  186.     s = "ABC"
  187.     Set lstEnumRef = lstEnum
  188. End Sub
  189.  
  190. Private Sub Form_Activate()
  191.     opt(0) = True
  192. End Sub
  193.  
  194. Private Sub lstEnum_Click()
  195.     If eeCur = eeChildWindows Or eeCur = eeTopWindows Then
  196.         lblFound = GetWndInfo(lstEnum.ItemData(lstEnum.ListIndex))
  197.     End If
  198. End Sub
  199.  
  200. Private Sub opt_Click(Index As Integer)
  201.     Dim f As Long, c As Long
  202.     eeCur = Index
  203.     lstEnum.Clear
  204.     Select Case eeCur
  205.     Case eeTopWindows
  206.         f = EnumWindows(AddressOf EnumWndProc, c)
  207.         lblResult = "Window count: " & c
  208.     Case eeChildWindows
  209.         f = EnumChildWindows(GetDesktopWindow, AddressOf EnumWndProc, c)
  210.         lblResult = "Window count: " & c
  211.     Case eeFontFamilies
  212.         f = EnumFontFamilies(hDC, sNullStr, AddressOf EnumFontFamProc, c)
  213.         lblResult = "Font family count: " & c
  214.     Case eeResources
  215.         'Set nResType = New Collection
  216.         f = EnumResourceTypes(App.hInstance, AddressOf EnumResTypeProc, c)
  217.         lblResult = "Resource count: " & c
  218.     End Select
  219. End Sub
  220.